package com.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.item.mapper.ShopMapper;
import com.item.pojo.Shop;
import com.item.pojo.Vehicle;
import com.item.service.ShopService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements ShopService {

    @Override
    public Map<String, Object> findPage(Integer page, Integer limit, String storeName, Integer storeState) {
        Map<String, Object> map = new HashMap<>();
        PageHelper.startPage(page, limit, "sid desc");
        List<Shop> data = super.baseMapper.findPage(storeName, storeState);
        PageInfo<Shop> pageInfo = new PageInfo<>(data);
        long total = pageInfo.getTotal();
        map.put("code", 0);
        map.put("count", total);
        map.put("data", data);
        return map;
    }
}
